# 放在和dist同级目录下
base=$(pwd)
echo "now in "$base

cat << EOF > nginx.conf
server {
    listen 8080;
    listen [::]:8080;
    server_name _;

    root $base/dist;

    # Load configuration files for the default server block.
    location / {
        # 使用绝对路径或者相对于本配置文件的相对路径（需指定-p）
        alias $base/dist/;
        index index.html;
        try_files \$uri \$uri/ /index.html;
    }


    error_page 404 /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}
EOF

sudo cp nginx.conf /etc/nginx/conf.d/
sudo nginx -s stop
sleep 1
sudo nginx
echo "nginx started"